﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Steamrunner
{
    class HowToPlayScreen : Screen
    {
        Texture2D background = null;
        Texture2D title = null;

        string nextScreen;

        public Rectangle screenBoundaries;

        public HowToPlayScreen(ScreenManager screenManager, Game game)
            : base(screenManager, game)
        {
        }

        public override void Initialize()
        {            
            base.Initialize();
        }

        protected override void LoadContent()
        {
            screenBoundaries = Game.Window.ClientBounds;

            guiManager = new GuiManager(Game);

            Button button = new Button(Game, Spritebatch, "Images\\Menus\\htp_btmm", new Vector2(screenBoundaries.Width * 0.245f, screenBoundaries.Height * 0.855f), "MenuScreen");
            guiManager.AddButton(button);

            guiManager.Initialize();

            background = Game.Content.Load<Texture2D>(@"Images\Menus\background");
            title = Game.Content.Load<Texture2D>(@"Images\Menus\htp_title");
        }

        public override void Update(GameTime gameTime)
        {
            musicManager.Update(gameTime);

            inputManager.Update(gameTime);

            if (inputManager.JustPressed(Keys.W))
            {
                guiManager.JoystickUp();
                musicManager.PlaySound("buttonScrolling");
            }
            else if (inputManager.JustPressed(Keys.S))
            {
                guiManager.JoystickDown();
                musicManager.PlaySound("buttonScrolling");
            }

            if (inputManager.JustPressed(Keys.A) || inputManager.JustPressed(Keys.D))
            {
                nextScreen = guiManager.ButtonClicked();
                musicManager.PlaySound("buttonSelect");
                screenManager.CurrentScreen = nextScreen;
            }

            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            Spritebatch.Begin();

            Spritebatch.Draw(background, Vector2.Zero, Color.White);

            Spritebatch.Draw(title, Vector2.Zero, Color.White);

            guiManager.Draw(gameTime);

            Spritebatch.End();

            base.Draw(gameTime);
        }

        public override string GetNextScreen()
        {
            return nextScreen;
        }
    }
}
